<html>
<head><meta charset="utf-8"><title>const slicing · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20slicing.html">const slicing</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218911931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20slicing/near/218911931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20slicing.html#218911931">(Dec 05 2020 at 01:52)</a>:</h4>
<p>is there a #![feature] for <code>&amp;some_slice[index..]</code> in const contexts? (the slice is <code>&amp;[u8]</code>) or is that likely not going to work until traits in general work.</p>



<a name="218911947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20slicing/near/218911947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20slicing.html#218911947">(Dec 05 2020 at 01:53)</a>:</h4>
<p>i'm aware i can just track the index explicitly, it just gets painful.</p>



<a name="218915284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20slicing/near/218915284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20slicing.html#218915284">(Dec 05 2020 at 03:28)</a>:</h4>
<p>Oh, because it's a RangeFrom, not a usize, so it's not the built-in indexing.</p>
<p>Seems unlikely, because it wants to panic with an interesting message.</p>



<a name="219050235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20slicing/near/219050235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20slicing.html#219050235">(Dec 07 2020 at 08:01)</a>:</h4>
<p>We either need to make slicing slices and arrays an operation that MIR knows about, or we need to implement all the trait method logic for the slicing, which, as scottmcm noted, requires the formatting infrastructure so we can generate the panic message</p>



<a name="219056484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20slicing/near/219056484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20slicing.html#219056484">(Dec 07 2020 at 09:21)</a>:</h4>
<p>MIR has a way to slice arrays and slices. It is currently only used for slice patterns though.</p>



<a name="219067168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/const%20slicing/near/219067168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/const.20slicing.html#219067168">(Dec 07 2020 at 11:10)</a>:</h4>
<p>Yes, it will only work on slices with compile-time known start and end. We'd need something with a runtime value, which we don't have a concept for at this time</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>